chcp 65001

@ECHO OFF

SETLOCAL EnableDelayedExpansion
CALL set_local_env.bat
SET PATH=%PATH%;%NSIS_HOME%

IF NOT DEFINED WORKSPACE (@ECHO Environment variable 'WORKSPACE' NOT defined! & EXIT /B 1)
IF NOT DEFINED SEVENZIP (@ECHO Environment variable 'SEVENZIP' NOT defined! & EXIT /B 1)
IF NOT DEFINED GIT_COMMIT (@ECHO Environment variable 'GIT_COMMIT' NOT defined! & EXIT /B 1)
IF NOT DEFINED GIT_TAG_NAME (@ECHO Environment variable 'GIT_TAG_NAME' NOT defined! & EXIT /B 1)
IF NOT DEFINED GIT_TAG_MESSAGE (@ECHO Environment variable 'GIT_TAG_MESSAGE' NOT defined! & EXIT /B 1)
IF NOT DEFINED INSTALL_HOME (@ECHO Environment variable 'INSTALL_HOME' NOT defined! & EXIT /B 1)

set URL_NAME="QNMindMap"
set PRODUCT_NAME="全能思维导图"
set INSTALL_DIR="QNMindMap"
set EXE_NAME="QNMindMap.exe"
set ICONFILE="logo.ico"
set PRODUCT_VERSION="%GIT_TAG_NAME:~1%"
set PRODUCT_PUBLISHER="苏州妙吉信息科技有限公司"
set PRODUCT_WEB_SITE="http://lpb.mjdian.com/"
set SYSTEM_TYPE="lianxiang"

CD %WORKSPACE%

rem RMDIR /S /Q package\setupfiles\
rem md package\setupfiles\

cd package
rd Release_lianxiang\ /s /q
mkdir Release_lianxiang


xcopy "Bin\*" Release_lianxiang\ /s /y 
xcopy "Res_lianxiang\*" Release_lianxiang\ /s /y 

rem rd setupfiles\ /s /q
rem mkdir setupfiles

makensis  /INPUTCHARSET UTF8 /DURL_NAME=%URL_NAME% /DPRODUCT_NAME=%PRODUCT_NAME% /DEXE_NAME=%EXE_NAME% /DICONFILE=%ICONFILE% /DPRODUCT_VERSION=%PRODUCT_VERSION% /DPRODUCT_PUBLISHER=%PRODUCT_PUBLISHER% /DPRODUCT_WEB_SITE=%PRODUCT_WEB_SITE% /DINSTALL_DIR=%INSTALL_DIR% /DSYSTEM_TYPE=%SYSTEM_TYPE% package_lianxiang.nsi

IF [%GIT_TAG_NAME%]==[] (@ECHO The 'GIT_TAG_NAME' empty! & EXIT /B 1)
IF NOT [%GIT_TAG_NAME:~0,1%]==[r] (
IF NOT [%GIT_TAG_NAME:~0,1%]==[t] (@ECHO The 'GIT_TAG_NAME' INCORRECT! & EXIT /B 1)
)

SET INSTALL_TARGET_DIR=%PACKAGE_HOME%\QNMindMap
IF NOT EXIST %INSTALL_TARGET_DIR% MKDIR %INSTALL_TARGET_DIR%

xcopy "setupfiles\*.exe" %INSTALL_TARGET_DIR% /s /y 
cd ..

SET PACK_FILENAME=%INSTALL_TARGET_DIR%\setup_%PRODUCT_NAME%_%PRODUCT_VERSION%_x86.exe

ENDLOCAL & SET HISTORY_FILES=%HISTORY_FILES% %PACK_FILENAME%

